package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhPlatformSellpartsnotsale;
import com.ruoyi.zsyh.service.IZsyhPlatformSellpartsnotsaleService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品禁售区域Controller
 * 
 * @author yuexl
 * @date 2025-04-27
 */
@Controller
@RequestMapping("/zsyh/sellPartsNotSale")
public class ZsyhPlatformSellpartsnotsaleController extends BaseController
{
    private String prefix = "zsyh/sellPartsNotSale";

    @Autowired
    private IZsyhPlatformSellpartsnotsaleService zsyhPlatformSellpartsnotsaleService;

    @RequiresPermissions("zsyh:sellPartsNotSale:view")
    @GetMapping()
    public String sellPartsNotSale()
    {
        return prefix + "/sellPartsNotSale";
    }

    /**
     * 查询产品禁售区域列表
     */
    @RequiresPermissions("zsyh:sellPartsNotSale:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhPlatformSellpartsnotsale zsyhPlatformSellpartsnotsale)
    {
        startPage();
        List<ZsyhPlatformSellpartsnotsale> list = zsyhPlatformSellpartsnotsaleService.selectZsyhPlatformSellpartsnotsaleList(zsyhPlatformSellpartsnotsale);
        return getDataTable(list);
    }

    /**
     * 导出产品禁售区域列表
     */
    @RequiresPermissions("zsyh:sellPartsNotSale:export")
    @Log(title = "产品禁售区域", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhPlatformSellpartsnotsale zsyhPlatformSellpartsnotsale)
    {
        List<ZsyhPlatformSellpartsnotsale> list = zsyhPlatformSellpartsnotsaleService.selectZsyhPlatformSellpartsnotsaleList(zsyhPlatformSellpartsnotsale);
        ExcelUtil<ZsyhPlatformSellpartsnotsale> util = new ExcelUtil<ZsyhPlatformSellpartsnotsale>(ZsyhPlatformSellpartsnotsale.class);
        return util.exportExcel(list, "产品禁售区域数据");
    }

    /**
     * 新增产品禁售区域
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存产品禁售区域
     */
    @RequiresPermissions("zsyh:sellPartsNotSale:add")
    @Log(title = "产品禁售区域", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhPlatformSellpartsnotsale zsyhPlatformSellpartsnotsale)
    {
        return toAjax(zsyhPlatformSellpartsnotsaleService.insertZsyhPlatformSellpartsnotsale(zsyhPlatformSellpartsnotsale));
    }

    /**
     * 修改产品禁售区域
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ZsyhPlatformSellpartsnotsale zsyhPlatformSellpartsnotsale = zsyhPlatformSellpartsnotsaleService.selectZsyhPlatformSellpartsnotsaleById(id);
        mmap.put("zsyhPlatformSellpartsnotsale", zsyhPlatformSellpartsnotsale);
        return prefix + "/edit";
    }

    /**
     * 修改保存产品禁售区域
     */
    @RequiresPermissions("zsyh:sellPartsNotSale:edit")
    @Log(title = "产品禁售区域", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhPlatformSellpartsnotsale zsyhPlatformSellpartsnotsale)
    {
        return toAjax(zsyhPlatformSellpartsnotsaleService.updateZsyhPlatformSellpartsnotsale(zsyhPlatformSellpartsnotsale));
    }

    /**
     * 删除产品禁售区域
     */
    @RequiresPermissions("zsyh:sellPartsNotSale:remove")
    @Log(title = "产品禁售区域", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhPlatformSellpartsnotsaleService.deleteZsyhPlatformSellpartsnotsaleByIds(ids));
    }
}
